import Vue from 'vue'
import Main from './main.vue'

const YdLoadingConstructor = Vue.extend(Main)

const ydLoading = (options = {}) => {
  if (typeof options !== 'object') {
    console.error('options require is object')
    return
  }

  const parent = document.body

  const instance = new YdLoadingConstructor({
    el: document.createElement('div'),
    data: options
  })

  parent.appendChild(instance.$el)

  instance.showEvent()

  return instance
}

export default ydLoading
